package org.example.service.impl;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;

/**
 * @author zengxiaoyu
 * @date 2025/9/11 17:16
 */
@Component
public class E implements ApplicationContextAware, SmartInitializingSingleton {


    @Autowired
    private B b;
    private ApplicationContext applicationContext;

    public E() {
        System.out.println("E init");
    }
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
        A a = applicationContext.getBean(A.class);
        C c = applicationContext.getBean(C.class);
        D d = applicationContext.getBean(D.class);

    }

    @Override
    public void afterSingletonsInstantiated() {
        System.out.println("E afterSingletonsInstantiated:");
        System.out.println(this);
    }
}
